<template>
  <div>
    <!--1视图-->

    <el-container>
      <el-header></el-header>
      <el-container>
        <el-aside width="200px">

          <el-menu
              default-active="2"
              class="el-menu-vertical-demo"
              router
              >
            <el-submenu index="1" v-for="m in menus" v-bind:key="m.id">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{m.name}}</span>
              </template>
              <el-menu-item-group>
                <el-menu-item v-for="c in m.children" v-bind:key="c.id" :index="c.path">{{c.name}}</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>


        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>


  </div>

</template>

<script>
export default {
  name: "IndexView",
  data() {
    return {
      //2属性定义
      menus:[],
    }
  }, methods: {
    //3自定义方法
    getMenus(){
      this.axios.post("menu/list").then(res=>{
        this.menus=res.data.data;
      })
    }
  }, created() {
    //4.钩子函数
    this.getMenus();
  }
}
</script>

<style>
.el-header, .el-footer {
  background-color: #B3C0D1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 40px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>